import Vue from 'vue'
import LoginModule from './LoginWithJoin.vue'

/*vue文件为单独弹出的模块,js控制弹出隐藏状态以及初始状态*/
var LoginTemplate = Vue.extend({
    template: '<div><login-module V-bind:show.sync="ModuleShow" V-bind:id.sync="id"></login-module></div>',
    components: {
        LoginModule,
    }
})
var Login = new LoginTemplate({
    data: function () {
        return {
            ModuleShow: false,
            id:''
        }
    },
    methods: {
        show(id) {
            this.ModuleShow = true
            this.id = id
        },
        hidden() {
            this.ModuleShow = false
        }
    }
})
/*仅挂载一次*/
Login.$once('mount', function (target) {
    if (!document.getElementById('loginWithJoin')) {
        let div = document.createElement('div');
        div.setAttribute('id', 'loginWithJoin');
        document.body.appendChild(div);
    }
    target.$mount('#loginWithJoin');
})

export default module = function(){
    this.Login = Login;
}
module.show = function show(id) {
    Login.$emit('mount', Login);
    Login.show(id);
}
module.hidden = function hidden() {
    Login.hidden();
}

